<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    登录名：<input type="text">
    密码： <input type="text">
    验证码：<input type="text" id="num">
    <input type="text" id="ran" value="" onclick="randomNum(1000, 9999)">
    <button id="btn">登录</button>
    <script src="./js/utils.js"></script>
    <script>
        btn.onclick = function () {
            let num = document.getElementById('num').value - 0;
            let ran = document.getElementById('ran').value - 0;
            if (num == ran) {
                alert('登陆成功');
            } else {
                alert('验证码错误')
            }
        }
        ran.onclick = function () {
            ran.value = randomNum(1000, 9999);
        } 
    </script>
</body>

</html>